/**
 * 
 */
package br.coppe.coimbra.document.doc.type;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

import br.coppe.coimbra.document.doc.DocIF;

/**
 * @author phillipe
 *
 */
public class Txt extends DocumentType implements DocIF {

	public Txt(File file) {

		super(file);
	}

	@Override
	public String read() {

		StringBuilder content = new StringBuilder();	

		try {

			BufferedReader in = new BufferedReader(new FileReader(super.file.getAbsolutePath()));

			try {

				String line = "";
				while((line = in.readLine()) != null) 

					content.append(line + " ");

			}
			finally {

				in.close();

			}
		}
		catch (IOException ioe) {

			ioe.printStackTrace();

		}
		return content.toString();
	}

}
